package com.huabo.system.service.impl;

import com.huabo.system.mysql.entity.TblFlowBussinessMySql;
import com.huabo.system.mysql.mapper.TblFlowBussinessMySqlMapper;
import com.huabo.system.oracle.entity.TblFlowBussiness;
import com.huabo.system.oracle.mapper.TblFlowBussinessMapper;
import com.huabo.system.service.TblFlowBussinessService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

@Service
public class TblFlowBussinessServiceImpl implements TblFlowBussinessService {

    @Resource
    private TblFlowBussinessMapper tblFlowBussinessMapper;

    @Resource
    private TblFlowBussinessMySqlMapper tblFlowBussinessMySqlMapper;

    @Override
    public List<TblFlowBussiness> findByFlowud(String flowid, TblFlowBussiness bussiness) {
        return this.tblFlowBussinessMapper.findByBussinessnumber(flowid, bussiness);

    }

    @Override
    public List<TblFlowBussinessMySql> findByMySqlFlowud(String flowid, TblFlowBussinessMySql bussiness) {
        return this.tblFlowBussinessMySqlMapper.findByBussinessnumber(flowid, bussiness);
    }

    @Override
    public void delete(TblFlowBussiness flowid) {
        tblFlowBussinessMapper.deleteByBussinessid(flowid.getBussinessid());
    }

    @Override
    public void deleteMySql(TblFlowBussinessMySql flowid) {
        tblFlowBussinessMySqlMapper.deleteByBussinessid(flowid.getBussinessid());
    }

    @Override
    public void save(TblFlowBussiness riskBussiness) {
        tblFlowBussinessMapper.insertSelective(riskBussiness);
    }

    @Override
    public void saveMySql(TblFlowBussinessMySql tblFlowBussinessMySql) {
        tblFlowBussinessMySqlMapper.insertSelective(tblFlowBussinessMySql);
    }

    @Override
    public TblFlowBussiness findUniqueByFlowId(BigDecimal flowid) {
        List<TblFlowBussiness> list = tblFlowBussinessMapper.findByflowid(flowid);
        if (list != null && list.size() != 0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public TblFlowBussinessMySql findUniqueByMySqlFlowId(BigDecimal flowid) {
        List<TblFlowBussinessMySql> list = tblFlowBussinessMySqlMapper.findByflowid(flowid);
        if (list != null && list.size() != 0) {
            return list.get(0);
        }
        return null;
    }
}
